package enums.enumeration04;

public class EnumMethod {
    public static void main(String[] args) {

        Season autumn = Season.AUTUMN;
        //输出该枚举对象的名字
        System.out.println(autumn.name());
        //输出该枚举对象的次序(从0开始编号)
        System.out.println(autumn.ordinal());
        //从反编译可以看到values方法，返回Season[]
        //含有定义的所有枚举对象
        Season[] values = Season.values();
        //遍历取出枚举对象
        for (Season season: values) {
            System.out.println(season);
        }
        System.out.println(Season.valueOf("AUTUMN"));

        System.out.println(Season.AUTUMN.compareTo(Season.SUMMER));
    }
}

enum Season {
    SPRING("春天", "温暖"), //常量名(实参列表)
    WINTER("冬天", "寒冷"),
    SUMMER("夏天", "炎热"),
    AUTUMN("秋天", "凉爽");

    private String name;
    private String desc;

    public String getName() {
       return name;
    }

    public String getDesc() {
       return desc;
    }

    private Season(String name, String desc) {
       this.name = name;
       this.desc = desc;
    }

    @Override
    public String toString() {
        return "Season{name=" + name + "desc=" + desc;
    }
}